//
//  PolicyTableViewCell.m
//  Village
//
//  Created by longrise on 2017/9/6.
//  Copyright © 2017年 程虎. All rights reserved.
//

#import "PolicyTableViewCell.h"
#import "UITableViewCell+FSAutoCountHeight.h"



@implementation PolicyTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
       
        self.contentLab = [[UILabel alloc]init];
        self.contentLab.font = [UIFont systemFontOfSize:16*kScreenScaleX];
        [self.contentLab sizeToFit];
        self.contentLab.numberOfLines = 0;
        [self.contentView addSubview:self.contentLab];
        
        self.contentImageView = [[UIImageView alloc]init];
        //        self.contentImageView.frame = CGRectMake(15, 15, 85, 64);
        [self.contentImageView sizeToFit];
        self.contentImageView.layer.cornerRadius=5.0f;// 将图层的边框设置为圆角
        self.contentImageView.layer.masksToBounds=YES;// 隐藏边界
        [self.contentView addSubview:self.contentImageView];
        
        self.nameLab = [[UILabel alloc]init];
        self.nameLab.font = [UIFont systemFontOfSize:11*kScreenScaleX];
        [self.nameLab sizeToFit];
        self.nameLab.textColor = [UIColor colorWithRed:217/255.0 green:215/255.0 blue:224/255.0 alpha:1];
        [self.contentView addSubview:self.nameLab];
        
        {
            
                        [self.contentImageView mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.top.equalTo(self.contentView.mas_top).with.offset(15*kScreenScaleY);
                            make.left.equalTo(self.contentView.mas_left).with.offset(10*kScreenScaleX);
                            make.width.mas_equalTo(86*kScreenScaleX);
                             make.height.mas_equalTo(kNavHeight*kScreenScaleY);
                        }];
    
                        [self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.top.equalTo(self.contentView.mas_top).with.offset(19*kScreenScaleY);
                            make.left.equalTo(self.contentImageView.mas_right).with.offset(15*kScreenScaleX);
                            make.right.lessThanOrEqualTo(self.contentView.mas_right).with.offset(-10*kScreenScaleX);
                        }];
          
            
                        [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
                            make.top.equalTo(self.contentLab.mas_bottom).with.offset(10*kScreenScaleY);
                            make.left.mas_equalTo(self.contentLab);
                        }];
            
            
        }
    }
    self.FS_cellBottomView = self.nameLab;//尽量传入底视图，不传也不会报错
    return self;
}


- (void)setpolicy:(PolicyModel *)entity
{
    
    self.contentLab.textColor =  [Util colorWithHexString:@"333333"];
    self.nameLab.textColor =   [Util colorWithHexString:@"bbbbbb"];
    NSString *stry = [NSString stringWithFormat:@"%@·1小时前   567阅读",entity.publishcom];
    self.contentLab.text = entity.content;
    self.nameLab.text = stry;
}


- (void)setEntity:(FSEntity *)entity
{
   
    self.contentLab.textColor =  [Util colorWithHexString:@"333333"];
    self.nameLab.textColor =   [Util colorWithHexString:@"bbbbbb"];
    NSLog(@"++++++++++++++++++++++++++++++++++++%@",entity.imageName);
    NSString *stry = [NSString stringWithFormat:@"%@·1小时前   567阅读",entity.username];
    

    self.contentLab.text = entity.content;
    self.contentImageView.image = [UIImage imageNamed:entity.imageName];
    self.nameLab.text = stry;
   }

@end
